from base import SF
import base64


class B85Sf(SF):
    '''
    B85加密
    '''
    def get_content(self, content: bytes) -> bytes:  # 加密
        return base64.b85encode(content)

    def put_content(self, pas_content: bytes) -> bytes:  # 解密
        return base64.b85decode(pas_content)


class B32Sf(SF):
    '''
    B32方法
    '''

    def get_content(self, content: bytes) -> bytes:  # 加密
        return base64.b32encode(content)

    def put_content(self, pas_content: bytes) -> bytes:  # 解密
        return base64.b32decode(pas_content)


class B16Sf(SF):
    '''
    B64
    '''

    def get_content(self, content: bytes) -> bytes:
        return base64.b64encode(content)

    def put_content(self, pas_content: bytes) -> bytes:
        return base64.b64decode(pas_content)


class KaiSha(SF):
    '''
    凯撒密码
    '''
    k = 3

    def get_content(self, content: bytes) -> bytes:
        con_li = list(content.decode())
        for i in range(0, len(con_li)):
            if (ord(con_li[i]) > self.k) or (ord(con_li[i]) <= 123):  # 加密
                con_li[i] = chr(ord(con_li[i])-self.k)

        return ''.join(con_li).encode()

    def put_content(self, pas_content: bytes) -> bytes:
        con_li = list(pas_content.decode())
        for i in range(0, len(con_li)):
            if (ord(con_li[i]) > self.k) or (ord(con_li[i]) <= 123):  # 解密
                con_li[i] = chr(ord(con_li[i]) + self.k)

        return ''.join(con_li).encode()





